<script setup lang="ts">
import { ref } from 'vue';
import {showFailToast, showToast} from 'vant';
import {useRouter}  from "vue-router";
import {getTeamList} from "@/api/team.ts";
import TeamcordList from "@/components/TeamcordList.vue";

const router = useRouter();
const value = ref('');
const teamList = ref([]);

const onSearch = (val = '') => {
    getTeamList(value.value).then((res)=>{
      if(res.data.data){
        teamList.value = res.data.data
      }
      else{
        showFailToast(res.data.description)
      }
    }).catch((err) =>{

    })
};
const onCancel = () => {
  router.back()
};


</script>

<template>
  <form action="/">
    <van-search
        v-model="value"
        show-action
        placeholder="请输入搜索关键词"
        @search="onSearch"
        @cancel="onCancel"
    />
  </form>
  <TeamcordList :TeamList="teamList"></TeamcordList>

</template>

<style scoped>

</style>